import './App.css';
import React from 'react'
import Child1 from './components/chlid1';
class App extends React.Component {
  state = {
    count: 0,
    msg: '子组件调用',
    list: [1, 2, 3],
    info: { uname: 'wqw', sex: 1 }
  }
  constructor() {
    super()
    // this.state = {

    // }
  }

  render() {
    return (
      <div>
        {/* <h1>{this.state.count}</h1>
        <button type='button' onClick={()=>{
          // this.setState({
          //   count: this.state.count + 1
          // })

          this.setState((preState,props)=>{
            return {
              count:preState.count + 1
            }
          },()=>{
            console.log(this.state.count);
          })
        }}>增加</button> */}

        {/* 子组件调用 */}
        <hr />
        <button type='button' onClick={() => {
          this.setState({
            msg: this.state.msg + '1'
          })
        }}>修改Msg</button>
        {/* <Child1 msg={this.state.msg} list={this.state.list} info={this.state.info} /> */}
        {/* 通过把state 展开，就自动把里面的状态属性，做同名的Props传给子组件*/}
        <Child1 {...this.state}></Child1>
        <hr />

      </div>
    )
  }
}

export default App;
